package cn.ycms.jdbc.support;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

import cn.ycms.jdbc.ColumnBean;
import cn.ycms.jdbc.RowMapper;


public class ColumnBeanMapper implements RowMapper<ColumnBean[]> {

	public ColumnBean[] mapper(ResultSet rs) throws SQLException {
		ResultSetMetaData rmd = rs.getMetaData();
		int count = rmd.getColumnCount();
		ColumnBean[] columns = new ColumnBean[count];
		for (int i = 0; i < count; i++) {
			ColumnBean column = new ColumnBean();
			column.setColumnLength(rmd.getColumnDisplaySize(i + 1));
			column.setColumnType(rmd.getColumnType(i + 1));
			column.setColumnName(rmd.getColumnName(i + 1));
		
			columns[i] = column;
		}
		return columns;
	}

}
